package com.maxsalad.uc.service;

import com.maxsalad.common.message.MessageResult;
import com.maxsalad.uc.dao.DishDao;
import com.maxsalad.uc.pojo.TDishEntity;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created by 2014-400 on 2016-03-16.
 */
@Service
public class DishService extends BaseService {
    private static final Logger log = LoggerFactory.getLogger(DishService.class);
    @Autowired
    private DishDao dishDao;

    public Map queryAllDish(TDishEntity dishEntity) throws Exception {
        return dishDao.queryAllDish(dishEntity);
    }

    public MessageResult saveOrUpdateDish(TDishEntity dishEntity) throws Exception {
        if (StringUtils.isBlank(dishEntity.getBarcode())) {
            return getMessageResult("E00012");
        }
        if (StringUtils.isBlank(dishEntity.getDishName())) {
            return getMessageResult("E00013");
        }
        dishDao.saveOrUpdate(dishEntity);
        return getMessageResult("S00001");
    }

    public MessageResult deletePlatform(long id) {
        dishDao.delete(id);
        return getMessageResult("S00001");
    }
}
